import { Component, InjectionToken, OnInit } from '@angular/core';
import { AppService } from './services/app.service';
import { timer } from 'rxjs';

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit {
  title = 'sso-client1'
  isLoggedIn = false;

  constructor(private _appService: AppService) { }

  ngOnInit(): void {
    this.isLoggedIn = this._appService.checkCredentials();

    // Refresh token every 1 hour
    timer(3600 * 1000).subscribe((val) => {
      console.log(`refresh count ${val}`);

      this._appService.refreshToken();
    });
  }
}

export const RES_URL = new InjectionToken("res_url");
export const SERVER_ADDR = new InjectionToken("server_addr");
export const REDIRECT_ADDR = new InjectionToken("redirect_addr");
